﻿using System;

using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Collections.Generic;
using System.Collections.Generic;

namespace devtm.Aop.Event
{

    public class MethodDefinitionBox
    {
        

        public MethodDefinitionBox(
            InterceptEnumEventType type, 
            MethodDefinition method, 
            int hashcode, 
            TypeDefinition typeInterceptor)
        {

            if (typeInterceptor == null)
            {
                typeInterceptor = method.DeclaringType;
                hashcode = typeInterceptor.GetHashCode();
            }

            this.Type = type;
            this.Method = method;
            this.Hashcode = hashcode;
            this.TypeInterceptor = typeInterceptor;

            MethodName = (method.ToString().Split('(')[0])
                .Replace("_", "")
                .Replace(".", "_")
                .Replace(":", "_")
                .Replace("<", "")
                .Replace(">", "")
                .Replace("+", "_")
                .Replace("_", "");

        }

        public MethodDefinition Method { get; set; }
        public InterceptEnumEventType Type { get; set; }        
        public Collection<CustomAttributeNamedArgument> Properties { get; set; }
        public int Hashcode { get; set; }
        public TypeDefinition TypeInterceptor { get; set; }

        public string MethodName { get; set; }

    }

}
